package com.demo.springcloud.controller;

import com.demo.springcloud.service.PaymentHystrixService;
import com.netflix.hystrix.contrib.javanica.annotation.DefaultProperties;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author :chenjie
 * @date :Created 2022/11/3 19:50
 */
@RestController
@Slf4j
//@DefaultProperties(defaultFallback = "paymentInfo_TimeOutHandler")//设置全局
public class OrderHystrixController {
    @Resource
    private PaymentHystrixService paymentHystrixService;

    @GetMapping("/consumer/payment/hystrix/timeout/{id}")
    //@HystrixCommand
    public String payment_TimeOut(@PathVariable("id") Integer id ){
        return paymentHystrixService.payment_TimeOut(id);
    }
    @GetMapping("/consumer/payment/hystrix/ok/{id}")
    public String payment_OK(@PathVariable("id") Integer id ){
        return paymentHystrixService.payment_OK(id);
    }
    public String paymentInfo_TimeOutHandler(Integer id){
        return "我是消费者80，对方支付系统繁忙请10秒之后重试";
    }
}
